package com.psm.listeners;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JTextField;

public class SplitOptionListener implements ActionListener
{
    JComboBox comboSplitOptions;
    JLabel lblFromPage;
    JTextField txtFromPage;
    JLabel lblToPage;
    JTextField txtToPage;
    
    public SplitOptionListener(JComboBox comboSplitOptions, JLabel lblFromPage, JTextField txtFromPage, JLabel lblToPage, JTextField txtToPage)
    {
        this.comboSplitOptions = comboSplitOptions;
        this.lblFromPage = lblFromPage;
        this.txtFromPage = txtFromPage;
        this.lblToPage = lblToPage;
        this.txtToPage = txtToPage;
    }

    @Override
    public void actionPerformed(ActionEvent ae)
    {
        if ( ae.getSource() ==  comboSplitOptions)
        {
            String selectedSplitOption = (String) comboSplitOptions.getSelectedItem();
            if("Extract page".equals( selectedSplitOption ))
            {
        	lblFromPage.setEnabled( true );
        	txtFromPage.setEnabled( true );
        	lblToPage.setEnabled( true );
        	txtToPage.setEnabled( true );
            }
            else
            {
        	lblFromPage.setEnabled( false );
        	txtFromPage.setEnabled( false );
        	lblToPage.setEnabled( false );
        	txtToPage.setEnabled( false );
            }
        }
    }

}
